package com.wanxi.step07test.controller;


import com.wanxi.step07test.dto.ResultDTO;
import com.wanxi.step07test.model.BusinessModel;
import com.wanxi.step07test.service.impl.BusinessServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@CrossOrigin
public class BusinessController {

    @Autowired
    private BusinessServiceImpl businessService;



    @PreAuthorize("hasAuthority('business:findAll')")
    @RequestMapping("/back/business/findAll")
    @ResponseBody
    public ResultDTO findAll(BusinessModel business) {
        ResultDTO resultDTO = businessService.findAll(business);
        return resultDTO;
    }



    @PreAuthorize("hasAuthority('business:add')")
    @RequestMapping("/back/business/add")
    @ResponseBody
    public ResultDTO add(BusinessModel business) {

        ResultDTO resultDTO = businessService.add(business);
        return resultDTO;
    }


    @PreAuthorize("hasAuthority('business:delete')")
    @RequestMapping("/back/business/delete")
    @ResponseBody
    public ResultDTO delete(BusinessModel business) {

        ResultDTO resultDTO = businessService.delete(business);
        return resultDTO;
    }


    @PreAuthorize("hasAuthority('business:findById')")
    @RequestMapping("/back/business/findById")
    @ResponseBody
    public ResultDTO findById(BusinessModel business) {
        ResultDTO resultDTO = businessService.findById(business);
        return resultDTO;
    }



    @PreAuthorize("hasAuthority('business:update')")
    @RequestMapping("/back/business/update")
    @ResponseBody
    public ResultDTO update(BusinessModel business) {

        ResultDTO resultDTO = businessService.update(business);
        return resultDTO;
    }


}
